package com.edu.his.service.impl;

import com.edu.his.domain.CheckRequest;
import com.edu.his.mapper.CheckRequestMapper;
import com.edu.his.service.CheckRequestService;
import com.edu.his.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 描述：
 * 创建人：飘
 * 创建时间：2024/12/16
 **/
@Service
public class CheckRequestServiceImpl implements CheckRequestService{

    @Autowired
    private CheckRequestMapper checkRequestMapper;

    @Override
    public R insert(CheckRequest checkRequest) {
        return R.success(200,"检查申请成功",this.checkRequestMapper.insert(checkRequest));
    }

    @Override
    public R updateState(Integer[] ids, int state) {
        //状态(1-已开立,2-已缴费,3执行完成,4-已出结果,5-已退费,6-已作废)
        String checkState="";
        switch (state)
        {
            case 1:
                checkState="已开立";
                break;
            case 2:
                checkState="已缴费";
                break;
            case 3:
                checkState="执行完成";
                break;
            case 4:
                checkState="已出结果";
                break;
            case 5:
                checkState="已退费";
                break;
            case 6:
                checkState="已作废";
                break;
            default:
                checkState="";
                break;
        }
        for(int id:ids)
        {
            CheckRequest checkRequest=new CheckRequest();
            checkRequest.setId(id);
            checkRequest.setCheckState(checkState);
            //调用方法修改状态
            this.checkRequestMapper.updateState(checkRequest);
        }
        return R.success(200,"修改状态成功",ids.length);
    }

    @Override
    public R updateCheck(CheckRequest checkRequest) {
        return R.success(200,"修改成功",this.checkRequestMapper.updateCheck(checkRequest));
    }

    @Override
    public R updateInpuCheck(CheckRequest checkRequest) {
        return R.success(200,"修改成功",this.checkRequestMapper.updateInpuCheck(checkRequest));
    }

    @Override
    public R selectByRegisgerAndMedicalTonologId(Integer registerId, Integer medicalTechnologyId) {
        return R.success(200,"查询成功",this.checkRequestMapper.selectByRegisgerAndMedicalTonologId(registerId,medicalTechnologyId));
    }


}
